package com.ruoyi.framework.config;

import com.baidu.aip.ocr.AipOcr;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.cvm.v20170312.CvmClient;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.GeneralBasicOCRRequest;
import com.tencentcloudapi.ocr.v20181119.models.GeneralBasicOCRResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AipConfig {

    @Value("${ocr.baidu.appid}")
    private String appId;

    @Value("${ocr.baidu.apikey}")
    private String apiKey;

    @Value("${ocr.baidu.secretKey}")
    private String secretKey;


    @Value("${ocr.tx.appid}")
    private String appIdTx;

    @Value("${ocr.tx.apikey}")
    private String apiKeyTx;

    @Value("${ocr.tx.secretKey}")
    private String secretKeyTx;

    @Bean
    public AipOcr bosClient(){
        AipOcr client = new AipOcr(appId, apiKey, secretKey);
        return client;
    }

    @Bean
    public OcrClient ocrClient(){

        Credential cred = new Credential(apiKeyTx, secretKeyTx);
        // 实例化一个http选项，可选的，没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("ocr.tencentcloudapi.com");
        // 实例化一个client选项，可选的，没有特殊需求可以跳过
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        // 实例化要请求产品的client对象,clientProfile是可选的
        OcrClient client = new OcrClient(cred, "ap-shanghai", clientProfile);
        // 实例化一个请求对象,每个接口都会对应一个request对象
        //GeneralBasicOCRRequest req = new GeneralBasicOCRRequest();
        // 返回的resp是一个GeneralBasicOCRResponse的实例，与请求对象对应
        //GeneralBasicOCRResponse resp = client.GeneralBasicOCR(req);
        return client;
    }


}
